/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.guide.web;

import com.jeeplus.common.json.AjaxJson;
import com.jeeplus.core.web.BaseController;
import com.jeeplus.modules.guide.entity.MobileAreaType;
import com.jeeplus.modules.guide.service.MobileAreaService;
import com.jeeplus.modules.guide.service.MobileBusinessService;
import com.jeeplus.modules.guide.service.MobileMatterService;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 业务Controller
 * @author azj
 * @version 2021-5-15
 */
@RestController
@RequestMapping("/mobileArea")
@RequiredArgsConstructor
public class MobileAreaController extends BaseController {
	private final MobileBusinessService mobilebusinessService;
	private final MobileAreaService mobileAreaService;
	private final MobileMatterService mobileMatterService;

	/**
	 * listArea 获取区域集合
	 *
	 * @author azj
	 * @version 2020-04-24
	 */
	@RequiresPermissions("mobileArea:list")
	@GetMapping(value ="listAreaType")
	public AjaxJson listAreaType() {
		return AjaxJson.success().put("data",mobilebusinessService.listAreaType());
	}

	/**
	 * selectAreaId 获取某点位详细信息
	 * orgrizeId点位标识
	 * @author azj
	 * @version 2020-04-24
	 */
	@RequiresPermissions("mobileArea:view")
	@GetMapping(value ="selectAreaId")
	public AjaxJson selectAreaId(String orgrizeId) {
		return AjaxJson.success().put("data",mobileAreaService.selectAreaId(orgrizeId));
	}


	/**
	 * insertOrUpdateArea 新增点位信息
	 * mobileAreaType 点位实体类
	 * @author azj
	 * @version 2020-04-24
	 */
	@RequiresPermissions(value={"mobileArea:add" , "mobileArea:edit"})
	@PostMapping(value ="insertOrUpdateArea")
	public AjaxJson insertOrUpdateArea(MobileAreaType mobileAreaType) {
		mobileAreaService.insertOrUpdateArea(mobileAreaType);
		return AjaxJson.success();
	}

	/**
	 * delAreaId 删除某点位信息
	 * id点位id
	 * @author azj
	 * @version 2020-04-24
	 */
	@RequiresPermissions("mobileArea:del")
	@GetMapping(value ="delAreaId")
	public AjaxJson delAreaId(String id) {
		mobileAreaService.delAreaId(id);
		mobileMatterService.delBussinessArea(id);
		return AjaxJson.success();
	}

	/**
	 * selecCountAreaId 查询点位条数
	 * orgrizeId点位标识
	 * @author azj
	 * @version 2020-04-24
	 */
	@GetMapping(value ="selecCountAreaId")
	public AjaxJson selecCountAreaId(String orgrizeId){
		return AjaxJson.success().put("data",mobileAreaService.selecCountAreaId(orgrizeId));
	}

}
